using System.Configuration;

namespace ALinq.BBS.Common.Config
{
    public class RegisterElement : ConfigurationElement
    {
        [ConfigurationProperty("emailValidate", DefaultValue = false)]
        public bool EmailValidate
        {
            get { return (bool)this["emailValidate"]; }
            set { this["emailValidate"] = value; }
        }

        [ConfigurationProperty("interval", DefaultValue = 100)]
        public int RegisterInterval
        {
            get { return (int)this["interval"]; }
            set { this["interval"] = value; }
        }

        [ConfigurationProperty("emailPassword", DefaultValue = false)]
        public bool EmailPassword
        {
            get { return (bool)this["emailPassword"]; }
            set { this["emailPassword"] = value; }
        }

        [ConfigurationProperty("allowSameEamil", DefaultValue = true)]
        public bool AllowSameEamil
        {
            get { return (bool)this["allowSameEamil"]; }
            set { this["allowSameEamil"] = value; }
        }

        [ConfigurationProperty("passwordQuestions")]
        public PasswordQuestionCollection PasswordQuestions
        {
            get { return (PasswordQuestionCollection)base["passwordQuestions"]; }
        }
    }

    public class PasswordQuestionCollection : ConfigurationElementCollection
    {

        protected override ConfigurationElement CreateNewElement()
        {
            return new PasswordQuestion();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((PasswordQuestion)element).ID;
        }
    }

    public class PasswordQuestion : ConfigurationElement
    {
        [ConfigurationProperty("value")]
        public string Value
        {
            get { return (string)base["value"]; }
        }

        [ConfigurationProperty("id")]
        public int ID
        {
            get { return (int)base["id"]; }
        }
    }
}